package com.zzx.test.io;

import org.junit.Test;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

/**
 * @ClassName: HomeWork1
 * @Description: 练习1
 * @Author zhouzhixin
 * @Date 2021/12/2
 * @Version 1.0
 */
public class HomeWork1 {

    @Test
    public void test1() {
        String filePath1 = "e:\\MyTemp";
        String filePath2 = "e:\\MyTemp\\hello.txt";
        try (FileWriter fileWriter = new FileWriter(filePath2)) {
            File file = new File(filePath1);
            if (!file.exists()) {
                System.out.println(file.mkdirs());
            }
            File file1 = new File(filePath2);
            if (file1.exists()) {
                System.out.println("hello.txt已存在");
            } else {
                System.out.println(file1.createNewFile());
            }
            fileWriter.write("hello,world");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
